package cn.hrms.service.impl;

import cn.hrms.domain.Department;
import cn.hrms.mapper.DepartmentMapper;
import cn.hrms.service.IDepartmentService;
import cn.hrms.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 部门服务实现类
 */
@Service
@RequiredArgsConstructor
public class DepartmentServiceImpl implements IDepartmentService {
	private final DepartmentMapper departmentMapper;

	/**
	 * 查询部门管理
	 *
	 * @param deptId 部门管理主键
	 * @return 部门管理
	 */
	@Override
	public Department selectDepartmentByDeptNo(Long deptId) {
		return departmentMapper.selectDepartmentByDeptNo(deptId);
	}

	/**
	 * 查询部门管理列表
	 *
	 * @param department 部门管理
	 * @return 部门管理
	 */
	@Override
	public List<Department> selectDepartmentList(Department department) {
		return departmentMapper.selectDepartmentList(department);
	}

	/**
	 * 新增部门管理
	 *
	 * @param department 部门管理
	 * @return 结果
	 */
	@Override
	public int insertDepartment(Department department) {
		department.setCreateTime(DateUtils.getNowDate());
		department.setModifyTime(DateUtils.getNowDate());
		return departmentMapper.insertDepartment(department);
	}

	/**
	 * 修改部门管理
	 *
	 * @param department 部门管理
	 * @return 结果
	 */
	@Override
	public int updateDepartment(Department department) {
		department.setModifyTime(DateUtils.getNowDate());
		return departmentMapper.updateDepartment(department);
	}

	/**
	 * 批量删除部门管理
	 *
	 * @param deptIds 需要删除的部门管理主键
	 * @return 结果
	 */
	@Override
	public int deleteDepartmentByDeptNos(Long[] deptIds) {
		return departmentMapper.deleteDepartmentByDeptNos(deptIds);
	}

	/**
	 * 删除部门管理信息
	 *
	 * @param deptId 部门管理主键
	 * @return 结果
	 */
	@Override
	public int deleteDepartmentByDeptNo(Long deptId) {
		return departmentMapper.deleteDepartmentByDeptNo(deptId);
	}
}
